Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate no-op codegen option -Cinline-threshold=... #124712

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

Enselic
Copy link
Member

@Enselic Enselic commented May 4, 2024

This deprecates -Cinline-threshold since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.

Recommend using -Cllvm-args=--inline-threshold=... instead.

Closes #89742 which is E-help-wanted.

@rustbot
Copy link
Collaborator

rustbot commented May 4, 2024

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2024
@@ -1502,7 +1502,8 @@ options! {
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation"),
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
"set the threshold for inlining a function"),
"this option is deprecated and does nothing \
(consider using `-Cllvm-args=--inline-threshold=...`)"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this have any effect if they do?

Copy link
Member Author

@Enselic Enselic May 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that makes a difference. Building e.g. libstd with -Cllvm-args=--inline-threshold=100000 vs -Cllvm-args=--inline-threshold=2 reliably makes a big difference in the size of .text, namely 1594 kB vs 367 kB:

$ RUSTFLAGS="-Ccodegen-units=1 -Cllvm-args=--inline-threshold=100000" ./x build --stage 0 library/std
$ size ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/libstd.rlib
   text   ...
      0   ...
1594437   ...
$ RUSTFLAGS="-Ccodegen-units=1 -Cllvm-args=--inline-threshold=2" ./x build --stage 0 library/std
$ size ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/libstd.rlib
   text   ...
      0   ...
 367682   ...

Another example is bat with 33 MB vs 5.4 MB:

$ RUSTFLAGS="-Cllvm-args=--inline-threshold=2" cargo build --release
$ ls -hl target/release/bat
-rwxr-xr-x 2 martin martin 5.4M May  5 10:58 target/release/bat
$ RUSTFLAGS="-Cllvm-args=--inline-threshold=100000" cargo build --release
$ ls -hl target/release/bat
-rwxr-xr-x 2 martin martin 33M May  5 11:13 target/release/bat

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh neat, I'm surprised it does anything!

@ehuss
Copy link
Contributor

ehuss commented Jun 3, 2024

r? compiler

@rustbot rustbot assigned fmease and unassigned JohnTitor Jun 3, 2024
@fmease fmease added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Jun 13, 2024
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GH issue had a fair bit of discussion and ppl seemed to have mostly settled on deprecation + warning. While you've obviously taken the NOP (+ doc) approach, emitting a warning or remapping it to -C llvm-args=-inline-threshold= are still valid options.

Emitting a warning would've likely prevented the odyssey as reported in #89742 (comment). Not a fan of non-lint warnings (i.e., ones that cannot be suppressed) but I think it would make perfect sense here. -Cno-stack-check emits a warning for example (-Car=... doesn't OTOH).

Regarding remapping to LLVM's "new"(?) inline-threshold I'm not well-versed enough in the matter to be able to give any input on that. Apart from semantic differences compared to the OldPM days (which seems to be the case having read the discussion), I guess another factor are the guarantees we (want to) provide for -C* flags esp. wrt. alternative codegen backends (codegen_{cranelift,gcc} are still unstable ofc). I don't know anything about that, so I'll let sb. else take a look at this PR.

@fmease
Copy link
Member

fmease commented Jun 13, 2024

I'm pretty sure this needs a compiler FCP, therefore:
r? compiler-team

@rustbot rustbot assigned pnkfelix and unassigned fmease Jun 13, 2024
@@ -1502,7 +1502,8 @@ options! {
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation"),
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
Copy link
Member

@fmease fmease Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR: If the deprecation ends up getting accepted (rather than the remapping), please emit a warning like -Cno-stack-check does (and unlike -Car=... which we might want to change in a separate PR).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, including regression test.

Note that I also added this commit to this PR:

commit 651ff643ae68438213bded335ef47cc9c50d3039
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date:   Fri Jun 14 19:48:40 2024 +0200

    Fix typo in `-Cno-stack-check` deprecation warning

    The flag `--no-stack-check` does not exist:

        $ rustc --no-stack-check
        error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`?

@Enselic
Copy link
Member Author

Enselic commented Jun 14, 2024

remapping it to -C llvm-args=-inline-threshold=

Remapping would probably have been good in late 2021 instead of making -Cinline-threshold a no-op. If we do it now - almost three years later - it would arguable be just as surprising as when it stopped working.

Also, maintaining the mapping will be quite much work. There are several knobs in LLVM to tweak, and people will have opinions on how to do it. I foresee endless discussions on how we should do it exactly. And this problem is multiplied for each codegen backend. So given where we are today, I think it is best to not try to remap.

But emitting a warning like -Cno-stack-check does is a good idea. I will do that. Thanks for taking a look at my PR!

@Enselic Enselic force-pushed the deprecate-inline-threshold branch from be39c26 to 97c67ee Compare June 14, 2024 18:18
@Enselic Enselic changed the title Deprecate codegen option inline-threshold Deprecate no-op codegen option -Cinline-threshold=... Jun 14, 2024
The flag `--no-stack-check` does not exist:

    $ rustc --no-stack-check
    error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`?
This deprecates `-Cinline-threshold` since using it has no effect. This
has been the case since the new LLVM pass manager started being used,
more than 2 years ago.
@Enselic Enselic force-pushed the deprecate-inline-threshold branch from 97c67ee to f5f067b Compare June 14, 2024 18:26
@pnkfelix
Copy link
Member

pnkfelix commented Jun 24, 2024

i think our official process when it comes to changing the stable command line interface of rustc is the Major Change Proposal (MCP) process.

But this specific change strikes me largely as a bug fix where the PR author is trying to make the whole thing more coherent (while also making the actual change quite minimal), and I don't think it warrants an MCP.

So, I'm going to r+ (because I don't think we need to further delay landing this change), but I also am going to nominate this PR so that the T-compiler team can double-check whether I am right that there exists some CLI changes that do not warrant an MCP.

@bors r+

@bors
Copy link
Contributor

bors commented Jun 24, 2024

📌 Commit f5f067b has been approved by pnkfelix

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 24, 2024
@pnkfelix pnkfelix added the I-compiler-nominated The issue / PR has been nominated for discussion during a compiler team meeting. label Jun 24, 2024
@pnkfelix
Copy link
Member

(as an example of why I nominated this, the T-compiler team might want to discuss the valid feedback left by @fmease , in order to determine whether an MCP was in fact warranted here.)

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2024
…mpiler-errors

Rollup of 11 pull requests

Successful merges:

 - rust-lang#124460 (Show notice about  "never used" of Debug for enum)
 - rust-lang#124712 (Deprecate no-op codegen option `-Cinline-threshold=...`)
 - rust-lang#125082 (Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks.)
 - rust-lang#125575 (SmartPointer derive-macro)
 - rust-lang#126413 (compiletest: make the crash test error message abit more informative)
 - rust-lang#126673 (Ensure we don't accidentally succeed when we want to report an error)
 - rust-lang#126682 (coverage: Overhaul validation of the `#[coverage(..)]` attribute)
 - rust-lang#126899 (Suggest inline const blocks for array initialization)
 - rust-lang#126904 (Small fixme in core now that NonZero is generic)
 - rust-lang#126909 (add `@kobzol` to bootstrap team for triagebot)
 - rust-lang#126911 (Split the lifetimes of `MirBorrowckCtxt`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit faa28be into rust-lang:master Jun 24, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2024
Rollup merge of rust-lang#124712 - Enselic:deprecate-inline-threshold, r=pnkfelix

Deprecate no-op codegen option `-Cinline-threshold=...`

This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.

Recommend using `-Cllvm-args=--inline-threshold=...` instead.

Closes rust-lang#89742 which is E-help-wanted.
jannic added a commit to jannic/rp-hal that referenced this pull request Jul 26, 2024
jannic added a commit to jannic/rust that referenced this pull request Jul 26, 2024
jannic added a commit to jannic/rust that referenced this pull request Jul 26, 2024
jannic added a commit to jannic/rp2040-project-template that referenced this pull request Jul 26, 2024
9names pushed a commit to rp-rs/rp2040-project-template that referenced this pull request Jul 26, 2024
9names pushed a commit to rp-rs/rp-hal that referenced this pull request Jul 26, 2024
jaisnan pushed a commit to jaisnan/rust-dev that referenced this pull request Jul 29, 2024
Update Rust toolchain from nightly-2024-06-24 to nightly-2024-06-25
without any other source changes.
This is an automatically generated pull request. If any of the CI checks
fail, manual intervention is required. In such a case, review the
changes at https://github.com/rust-lang/rust from
rust-lang@bcf94de
up to
rust-lang@6b0f4b5.
The log for this commit range is:
rust-lang@6b0f4b5ec3 Auto merge of
rust-lang#126914 - compiler-errors:rollup-zx0hchm, r=compiler-errors
rust-lang@16bd6e25e1 Rollup merge of
rust-lang#126911 - oli-obk:do_not_count_errors, r=compiler-errors
rust-lang@59c258f51f Rollup merge of
rust-lang#126909 - onur-ozkan:add-kobzol, r=matthiaskrgr
rust-lang@85eb835a14 Rollup merge of
rust-lang#126904 - GrigorenkoPV:nonzero-fixme, r=joboet
rust-lang@a7721a0373 Rollup merge of
rust-lang#126899 - GrigorenkoPV:suggest-const-block, r=davidtwco
rust-lang@9ce2a070b3 Rollup merge of
rust-lang#126682 - Zalathar:coverage-attr, r=lcnr
rust-lang@49bdf460a2 Rollup merge of
rust-lang#126673 - oli-obk:dont_rely_on_err_reporting, r=compiler-errors
rust-lang@46e43984d1 Rollup merge of
rust-lang#126413 - matthiaskrgr:crshmsg, r=oli-obk
rust-lang@ed460d2eaa Rollup merge of
rust-lang#125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco
rust-lang@c77dc28f87 Rollup merge of
rust-lang#125082 - kpreid:const-uninit, r=dtolnay
rust-lang@faa28be2f1 Rollup merge of
rust-lang#124712 - Enselic:deprecate-inline-threshold, r=pnkfelix
rust-lang@00e5f5886a Rollup merge of
rust-lang#124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix
rust-lang@d8d5732456 Auto merge of
rust-lang#126784 - scottmcm:smaller-terminator, r=compiler-errors
rust-lang@13fca73f49 Replace
`MaybeUninit::uninit_array()` with array repeat expression.
rust-lang@5a3e2a4e92 Auto merge of
rust-lang#126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrum
rust-lang@45261ff2ec add @Kobzol to
bootstrap team for triagebot
rust-lang@84474a25a4 Small fixme in core
now that NonZero is generic
rust-lang@50a02ed789 std: fix wasm builds
rust-lang@8fc6b3de19 Separate the mir
body lifetime from the other lifetimes
rust-lang@1c4d0ced58 Separate the
lifetimes of the `BorrowckInferCtxt` from the other borrowed items
rust-lang@d371d17496 Auto merge of
rust-lang#126900 - matthiaskrgr:rollup-24ah97b, r=matthiaskrgr
rust-lang@8ffb5f936a compiletest: make
the crash test error message abit more informative
rust-lang@a80ee9159b Rollup merge of
rust-lang#126882 - estebank:multiline-order, r=WaffleLapkin
rust-lang@8bfde609e2 Rollup merge of
rust-lang#126414 - ChrisDenton:target-known, r=Nilstrieb
rust-lang@94b9ea417d Rollup merge of
rust-lang#126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb
rust-lang@9d24ecc37b Rollup merge of
rust-lang#125241 - Veykril:tool-rust-analyzer, r=davidtwco
rust-lang@ba5ec1fc5c Suggest inline const
blocks for array initialization
rust-lang@06c072f158 Auto merge of
rust-lang#126788 - GuillaumeGomez:migrate-rustdoc-tests-syntax, r=fmease,oli-obk
rust-lang@1852141219 coverage: Bless
coverage attribute tests
rust-lang@b7c057c9b2 coverage: Always
error on `#[coverage(..)]` in unexpected places
rust-lang@a000fa8b54 coverage: Tighten
validation of `#[coverage(off)]` and `#[coverage(on)]`
rust-lang@b5dfeba0e1 coverage: Forbid
multiple `#[coverage(..)]` attributes
rust-lang@6909feab8e Allow numbers in
rustdoc tests commands
rust-lang@4e258bb4c3 Fix tidy issue for
rustdoc tests commands
rust-lang@51fedf65ff Remove commands
duplication between `compiletest` and `tests/rustdoc`
rust-lang@1b67035579 Update
`tests/rustdoc` to new test syntax
rust-lang@d3ec92e16e Move `tests/rustdoc`
testsuite to `//@` syntax
rust-lang@2c243d9570 Auto merge of
rust-lang#126891 - matthiaskrgr:rollup-p6dl1gk, r=matthiaskrgr
rust-lang@b94d2754b5 Rollup merge of
rust-lang#126888 - compiler-errors:oops-debug-printing, r=dtolnay
rust-lang@9892b3e9fe Rollup merge of
rust-lang#126854 - devnexen:std_unix_os_fallback_upd, r=Mark-Simulacrum
rust-lang@3108dfaced Rollup merge of
rust-lang#126849 - workingjubilee:correctly-classify-arm-low-dregs, r=Amanieu
rust-lang@dcace866f0 Rollup merge of
rust-lang#126845 - rust-lang:cargo_update, r=Mark-Simulacrum
rust-lang@21850f5bd8 Rollup merge of
rust-lang#126807 - devnexen:copy_file_macos_simpl, r=Mark-Simulacrum
rust-lang@b24e3df0df Rollup merge of
rust-lang#126754 - compiler-errors:use-rustfmt, r=calebcartwright
rust-lang@ad0531ae0d Rollup merge of
rust-lang#126455 - surechen:fix_126222, r=estebank
rust-lang@7babf99ea9 Rollup merge of
rust-lang#126298 - heiher:loongarch64-musl-ci, r=Mark-Simulacrum
rust-lang@9a591ea1ce Rollup merge of
rust-lang#126177 - carbotaniuman:unsafe_attr_errors, r=jieyouxu
rust-lang@25446c25fc Remove stray println
from rustfmt
rust-lang@d49994b060 Auto merge of
rust-lang#126023 - amandasystems:you-dropped-this-again, r=nikomatsakis
rust-lang@a23917cfd0 Add hard error and
migration lint for unsafe attrs
rust-lang@284437d434 Special case when a
code line only has multiline span starts
rust-lang@f1be59fa72 SmartPointer
derive-macro
rust-lang@a426d6fdf0 Implement use<>
formatting in rustfmt
rust-lang@16fef40896 Promote
loongarch64-unknown-linux-musl to Tier 2 with host tools
rust-lang@03d73fa6ba ci: Add support for
dist-loongarch64-musl
rust-lang@fc50acae90 fix build
rust-lang@bd9ce3e074
std::unix::os::home_dir: fallback's optimisation.
rust-lang@0d8f734172 compiler: Fix arm32
asm issues by hierarchically sorting reg classes
rust-lang@e8b5ba1111 For [E0308]:
mismatched types, when expr is in an arm's body, not add semicolon ';'
at the end of it.
rust-lang@990535723d cargo update
rust-lang@b28efb11af Save 2 pointers in
`TerminatorKind` (96 → 80 bytes)
rust-lang@65530ba100 std::unix::fs: copy
simplification for apple.
rust-lang@339015920d Add `rust_analyzer`
as a predefined tool
rust-lang@3f2f8438b4 Ensure we don't
accidentally succeed when we want to report an error
rust-lang@32f9b8bf76 std: rename module
for clarity
rust-lang@35f050b8da std: update TLS
module documentation
rust-lang@b2f29edc81 std: use the `c_int`
from `core::ffi` instead of `libc`
rust-lang@d70f071392 std: simplify
`#[cfg]`s for TLS
rust-lang@d630f5da7a Show notice about
"never used" for enum
rust-lang@f3facf1175 std: refactor the
TLS implementation
rust-lang@f5f067bf9d Deprecate no-op
codegen option `-Cinline-threshold=...`
rust-lang@651ff643ae Fix typo in
`-Cno-stack-check` deprecation warning
rust-lang@3af624272a rustc_codegen_ssa:
Remove unused ModuleConfig::inline_threshold
rust-lang@34e6ea1446 Tier 2 std support
must always be known
rust-lang@2d4cb7aa5a Update docs for
AtomicU8/I8.
rust-lang@7885c7b7b2 Update safety docs
for AtomicBool::from_ptr.
rust-lang@7b5b7a7010 Remove confusing
`use_polonius` flag and do less cloning

Co-authored-by: tautschnig <1144736+tautschnig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-compiler-nominated The issue / PR has been nominated for discussion during a compiler team meeting. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-C inline-threshold has no effect with new LLVM pass manager
8 participants